Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237
Open
mshayriyesaricicek wants to merge 9 commits intoCodeYourFuture:mainfrom
Open
Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | practice tdd#1237mshayriyesaricicek wants to merge 9 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek wants to merge 9 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Mar 13, 2026
cjyuan
reviewed
Mar 15, 2026
Comment on lines
+27
to
+31
| expect(countChar("aaaaa", 'b")).toEqual(5); | ||
| expect(countChar("blind", 'a)).toEqual(0); | ||
| expect(countChar("blood", 'o")).toEqual(2); | ||
| expect(countChar("bbbrf", 'b")).toEqual(3); | ||
| expect(countChar("ooooa", 'o")).toEqual(4); |
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| // Check if input is a number | ||
| if (typeof num !== "number" || isNaN(num)) || !Number.isInteger(num) || !Number.isFinite(num)) { |
Contributor
There was a problem hiding this comment.
This will ensure num is integer, but some of the checks are redundant.
Can you delete those that are redundant?
| throw new Error("Input must be a valid number"); | ||
| } | ||
|
|
||
| const lastnum = num % 10; // checks what last number is |
Contributor
There was a problem hiding this comment.
Note: The convention is to name variable in camelCase. For examples, lastNum or lastDigit.
Comment on lines
+47
to
+51
| test("should append 'th' if nunber is 11 or does not end in 1, 2 or 3 ", () => { | ||
| expect(getOrdinalNumber(20)).toEqual("20th"); | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(99)).toEqual("99th"); | ||
| }); |
Contributor
There was a problem hiding this comment.
"should append 'th' if nunber is 11 or does not end in 1, 2 or 3" -- This description does not yet cover all the "remaining numbers". Can you revise it?
Comment on lines
+24
to
+35
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hello"); | ||
| }); | ||
|
|
||
| // Case: Handle count of 0: | ||
| // Given a target string `str` and a `count` equal to 0, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return an empty string. | ||
| // If the the string is empty then count will be 0 | ||
| // and an empty string will be returned | ||
|
|
||
| test("should repeat the string count times", () => { |
Contributor
There was a problem hiding this comment.
These tests have the same description. When one of them fails, it may take one longer time to figure out which of these tests fails. Can you revise them to make the description distinct?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Changelist
This PR is to practice writing tests before writing functions